<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <title>我的订单</title>
    <link rel="stylesheet" href="/Public/Home/css/memberOrder.css">
    <!--不识别数字为手机-->
<meta name="format-detection" content="telephone=no, email=no"/>
<!--通用js-->
<?php if(isset($signPackage) && !empty($signPackage)){ ?>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js?v=201704270010"></script>
<?php } ?>
<script type="text/javascript" src="/Public/Home/js/require.js"></script>
<script type="text/javascript" src="/Public/Home/js/baseLoading.js?v=201705240001"></script>
<script src="/Public/Home/js/jquery.min.js" ></script>
<script src="/Public/Home/js/pincode-input.js" ></script>
<script src="/Public/Home/js/parabola.js" ></script>
<script src="/Public/Home/js/lazyload/jquery.lazyload.min.js"></script>
<script type="text/javascript">
    _global.isLogin = !!"<?php echo $wx_member_id; ?>";
	var isWxShareDiy = typeof yc_share_diy === "undefined" ? false : yc_share_diy;
	var yc_wx_shareImgPath = "";
	<?php if(isset($weixin_logo) && !empty($weixin_logo)){ ?>
		yc_wx_shareImgPath = "/Uploads/<?php echo ($weixin_logo["image"]); ?>";
	<?php } ?>
    var yc_pass_arr = {'local_id':"<?php echo I('local_id',1);?>",'top_local_id':"<?php echo I('top_local_id',1);?>"};
	if(parseInt(yc_pass_arr["local_id"]) == 21){
		_global.isStopSell = true;
	}
    <?php if(isset($signPackage) && !empty($signPackage)){ ?>
        _global.isWeiXinLoad = true;
        var isEnableLocation = typeof yc_wx_location === "undefined" ? false : yc_wx_location;
        var yc_wx_options = {
            "enableLocation" : isEnableLocation,
            "refuseCallback" : function(){},
            "mapCallback" : function(){},
            "config" : {
                debug: false,
                appId: '<?php echo $signPackage["appId"];?>',
                timestamp: '<?php echo $signPackage["timestamp"];?>',
                nonceStr: '<?php echo $signPackage["nonceStr"];?>',
                signature: '<?php echo $signPackage["signature"];?>',
                jsApiList: [
                    'checkJsApi'
                ]
            }
        };
        var isInHeader = typeof yc_wx_useInHeader === "undefined" ? true : yc_wx_useInHeader;
        if(isInHeader){
            wxAutoConfig(yc_wx_options);
        }
    <?php } ?>
</script>
</head>
<body>
<div class="warp">
    <!--订单类别-->
    <?php if($view != 7): ?><div class="member-order-category">
            <ul class="category-ui">
                <li <?php if($view == 6): ?>class="active"<?php endif; ?> data-oid="6"><span>全部</span></li>
                <li <?php if($view == 3 ): ?>class="active"<?php endif; ?> data-oid="3"><span>未支付</span></li>
                <li <?php if($view == 0 ): ?>class="active"<?php endif; ?> data-oid="0"><span>待发货</span></li>
                <li <?php if($view == 10 ): ?>class="active"<?php endif; ?> data-oid="10"><span>待收货</span></li>
                <li <?php if($view == 8 ): ?>class="active"<?php endif; ?> data-oid="8"><span>待评价</span></li>
            </ul>
        </div><?php endif; ?>
    <!-- 订单列表 -->
    <div class="member-order-list">
    </div>
</div>
<div class="alert-popup askorder-reminder" style="display:none">
    <p style="display:block;">如果您的订单还没有发货，可以拨打 <span class="tel"></span>联络发货人。</p>
    <p><a href="javascript:void(0);" class="cancel">取消</a><a href="javascript:void(0);" class="confirm bdtel">拨打</a></p>
</div>
<div class="alert-popup operate-reminder" style="display:none">
    <p class="msg">是否取消订单？</p>
    <p><a href="javascript:void(0);" class="confirm">确定</a><a href="javascript:void(0);" class="cancel">取消</a></p>
</div>

<!-- 子类主菜单 -->
<div class="subclass-main-nav">
    <div class="subclass-main-on"><a href="javascript:void(0)"><span>快速导航</span></a></div>
</div>
<div class="subclass-main-menu" style="display: none;">
    <div class="subclass-main-off"><a href="javascript:void(0)" class="close"><span>快速导航</span></a></div>
    <div class="subclass-main-menu-demo">
        <a href="<?php echo url('store/index');?>" class="home active"><span></span><p>首页</p></a>
        <a href="<?php echo url('category/index');?>" class="category"><span></span><p>分类</p></a>

        <?php $qgs_id = ($_GET['local_id']=='11') ? $_GET['top_local_id'] : $_GET['local_id']; ?>
        <a href="<?php echo url('store/index', ['local_id' => '11','top_local_id' => $qgs_id]);?>" class="store-way active"><span></span><p>全国送</p></a>
        <a href="<?php echo url('carts/cart');?>" class="cart"><span></span><p>购物车</p></a>
        <a href="<?php echo url('Member/index');?>" class="mine"><span></span><p>我的</p></a>
    </div>         
</div>


<?php $kuaidiurl = get_url() ?>
<script type="text/javascript">
	var topUrls = [];
	var curAjaxModeId = <?php echo I('view');?>;
    var kd_pre_url = "<?php echo ($kuaidiurl[top]); echo ($kuaidiurl[host]); ?>";
</script>    
<script type="text/javascript" src="/Public/Home/js/memberOrder.js?v=201703030001"></script>
<script type="text/javascript">
	require(['subClassMain']);
    var _isAjaxProcess = false;
	var _passJson = {"o" : null, "orderId" : null, "stat" : null};
	var _isFirst = true;
	function askOrder(telNumber){
		$(".askorder-reminder .tel").html(telNumber);
		$(".askorder-reminder .bdtel").attr("href", "tel://"+telNumber);
		_global.promote.popup(".askorder-reminder");
	}
	// 成功时候执行的方法
	function opSuccess(){
		var isDel = false;
		if(curAjaxModeId == 6 || curAjaxModeId == 7){
			var parent = $(_passJson["o"]).parents(".operate-position");
			var bgParent = $(_passJson["o"]).parents(".member-order-ycone");
			if(_passJson["stat"] == 3){
				isDel = true;
			}else if(_passJson["stat"] == 1){						
				parent.html(parent.find(".next-step").html());
				bgParent.find(".member-order-state").html("失效");
			}else if(_passJson["stat"] == 2){
				parent.html(parent.find(".next-step").html());
				bgParent.find(".member-order-state").html("待评价");
			}
		}else{
			isDel = true;
		}
		if(isDel){
			$(_passJson["o"]).parents('.member-order-ycone').remove();
		}
	}
	function opreateOrder(o, orderId, stat){
		_passJson["o"] = o;
		_passJson["orderId"] = orderId;
		_passJson["stat"] = stat;
		if(stat == 1){			
			$(".operate-reminder .msg").html("是否取消订单？");
		}else if(stat == 2){
			$(".operate-reminder .msg").html("是否确认收货？");
		}else if(stat == 3){
			$(".operate-reminder .msg").html("是否删除订单？");
		}
				
		_global.promote.popup(".operate-reminder", !_isFirst);
		
		if(_isFirst){
			_isFirst = false;
			$(".operate-reminder .confirm").click(function(e){
				ajaxOpreateOrder(_passJson["o"], _passJson["orderId"], _passJson["stat"]);
			});
		}		
	}
	
    function ajaxOpreateOrder(o, orderId, stat){
        if(_isAjaxProcess) return;
        _isAjaxProcess = true;
        _global.promote.loadPopup("正在处理中...");
        $.ajax({
            type: "POST",
            url: "<?php echo url('Member/cancelOrder');?>",
            data: { "order_id": orderId ,"stat": stat },
            dataType: "json",
            success: function (rs) {
                _global.promote.removeLoad();
                if(rs.stat)  {
                    opSuccess();
                }
                _global.promote.alertPopup(rs.msg);
                _isAjaxProcess = false;
            },
            error: function () {
                _global.promote.removeLoad();
                _global.promote.alertPopup('服务器异常，请稍后重试！');
                _isAjaxProcess = false;
            }
        });
    }
</script>
</body>
</html>